#!/bin/bash

EID=$(($1*10))
count=0

while [ $count -lt 12 ]; do
    busctl get-property au.com.codeconstruct.MCTP1 /au/com/codeconstruct/mctp1/networks/1/endpoints/"$EID" xyz.openbmc_project.MCTP.Endpoint EID
    isMctpConnect=$?;
    echo $isMctpConnect
    if [ $isMctpConnect -eq 0 ]; then
        echo "MCTP ETD $EID connection successfully."
        sleep 20
        exit 0;
    fi
    echo "MCTP EID $EID not connection yet."
    sleep 5;
    count=$((count + 1))
done

echo "timeout waiting for MCTP EID $EID connection."
exit 1
